import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

class MainImagePage extends StatefulWidget {
  @override
  _MainImagePageState createState() => _MainImagePageState();
}

class _MainImagePageState extends State<MainImagePage> {
  String img =
      "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1483802554,2802139947&fm=11&gp=0.jpg";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Image'),
        ),
        body: Container(
          child: Column(children: <Widget>[
            // 圆角照片 方式一
            // ClipOval(
            //     child: Container(
            //   color: Colors.green,
            //   child: Image(
            //       image: NetworkImage(img),
            //       width: 200,
            //       height: 200,
            //       fit: BoxFit.cover),
            // )),
            // 圆角照片方式二
            // CircleAvatar(backgroundImage: NetworkImage(img), radius: 200),
            // 圆角照片方式三
            // Container(
            //     color: Colors.grey,
            //     child: ClipRRect(
            //         child: FadeInImage.assetNetwork(
            //             placeholder: "images/2.0/logo.jpg", image: img),
            //         borderRadius: BorderRadius.all(Radius.circular(50)))),
            // 加载本地照片+加载缓存照片
            // CachedNetworkImage(
            //   imageUrl: img,
            //   placeholder: (context, url) => CircularProgressIndicator(),
            //   errorWidget: (context, url, error) => Icon(Icons.error),
            // ),
            // CachedNetworkImage(
            //   imageUrl: img,
            //   progressIndicatorBuilder: (context, url, downloadProgress) =>
            //       CircularProgressIndicator(value: downloadProgress.progress),
            //   errorWidget: (context, url, error) => Icon(Icons.error),
            // ),
            // Image(
            //     image: AssetImage("images/2.0/logo.jpg"),
            //     width: 200,
            //     height: 200),
            Image.asset("images/3.0/logo.jpg", width: 200, height: 200)
          ]),
        ));
  }
}
